package com.lhb.ojjudgeservice.judge;


import com.lhb.ojjudgeservice.judge.judgestrategy.DefaultJudgeStrategyImpl;
import com.lhb.ojjudgeservice.judge.judgestrategy.JavaJudgeStrategyImpl;
import com.lhb.ojjudgeservice.judge.judgestrategy.JudgeStrategy;
import com.lhb.ojjudgeservice.judge.judgestrategy.StrategyContext;
import com.lhb.ojmodel.model.dto.questionsubmit.JudgeInfo;
import org.springframework.stereotype.Service;

@Service
public class JudgeManager {

    //根据不同的语言，调用不同的策略
    public JudgeInfo judge(StrategyContext strategyContext) {
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategyImpl();
        String language = strategyContext.getQuestionSubmit().getLanguage();
        if("java".equals(language)){
            judgeStrategy = new JavaJudgeStrategyImpl();
        }
        JudgeInfo judgeInfo = judgeStrategy.judgeResult(strategyContext);
        return judgeInfo;
    }

}
